package org.ethanxu.ftpdownload.main;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;


/**
 * This is a file transfer sample with the minimum function.
 * Feel free to contact me if you have any question.
 * I'm just behind you. :)
 * <p>
 *
 * @author  EthanXu
 * 
 */
public class Client {
	public static void main(String[] args) throws Exception {
		Socket socket = new Socket("127.0.0.1", 1111);
		InputStream is = socket.getInputStream();
		OutputStream out = new FileOutputStream("D://to.jpg");
		byte[] b = new byte[128];
		int n;
		while((n = is.read(b))!=-1){
			out.write(b, 0, n);
		}
		out.close();
		is.close();
		socket.close();
	}
}
